#ifndef __EC5_H__
#define __EC5_H__

#include <string>

#include "log4cpp/Category.hh"
#include "log4cpp/FileAppender.hh"
#include "log4cpp/BasicLayout.hh"

typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;

typedef enum tagPKTState
{
    PKT_INIT,
    PKT_PROCESSING,
    PKT_WAIT_COMPLETE,    
}EC5_PKT_STATE_E;

typedef struct tagEC5_wfv
{
    uint8 amType;
    uint8 group;

    uint16 nodeId;
    uint8 socketId;

    uint8 boardId;
    uint8 packetId;
    uint16 parentId;

    uint16 E1ReferenceADC;
    uint16 E1ExcitationV;
    uint16 soilWaterContent;
    uint16 E1ExcitationADC;
    uint16 soilWaterContentADC;
}EC5_WFV_S;

#define EC5_BUFF_SIZE 1024

typedef struct EC5_BUFF
{
    EC5_PKT_STATE_E pktState;
    int size;
    int cur;
    char value[EC5_BUFF_SIZE];    
}EC5_BUFF_S;

typedef struct ec5MetaType
{
    std::string name;
    int byteoffset;
    int length;
    std::string type;    
}EC5_META_S;

typedef struct ec5MetaTypeCONVERSION
{
    std::string name;
    std::string function;
    std::vector<std::string> XConvParams;
}EC5_META_CONVERSION_S;

typedef struct ec5CondType
{
    std::string fieldname; 
    unsigned int fieldvalue;   
}EC5_XCOND_S;

extern log4cpp::Category *g_info_log;

std::string& repalce_all_ditinct(std::string& str,const std::string&old_value,const std::string& new_value);

double postfixCalculate2(std::string& postfix);

void parseEC5(const char* filename);
std::string bytes_to_hexstr(unsigned char* first, unsigned char* last);
void parseBuffer(unsigned char *buff, int length);

#endif /* __EC5_H__ */

/* end of file */
